package com.eshop.we.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.eshop.we.account.entity.Account;
import com.eshop.we.accountdetail.entity.AccountDetail;
import com.eshop.we.business.AccountBusiness;
import com.eshop.we.business.AccountDetailBusiness;
import com.eshop.we.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/account")
public class AccountController extends BaseController {

    @Autowired
    AccountBusiness accountBusiness;

    @Autowired
    AccountDetailBusiness accountDetailBusiness;

    @GetMapping("/getaccount")
    public Result getAccount(@RequestParam(required = true) Integer userId){

        Account account=new Account();
        account.setUserId(userId);
        EntityWrapper ew=  new EntityWrapper<Account>();
        ew.setEntity(account);
        return  Result.success(accountBusiness.selectOne(ew));

    }

    @GetMapping("/getaccountdetail")
    public Result getAccountDetail(@RequestParam(required = true)Integer accountId){
        return  Result.success(accountDetailBusiness.selectList(new EntityWrapper<AccountDetail>().eq("account_id",accountId)));
    }
}
